package rs.etf.es.visualization;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import javax.swing.text.DefaultCaret;

import rs.etf.es.algorithm.JTextAreaLogger;

public class MainWindow {

    public JFrame frmBayesianNetworkSimulator;
    public static NewNodeDialog newNodeDialog;
    private JMenuBar mnuMenuBar;
    private JMenu mnuFileMenu;
    private JMenuItem mnuLoadFromFile;
    private JMenuItem mnuExit;
    private JMenu mnuSimulation;
    private JMenuItem mnuNextStep;
    private JMenuItem mnuFinishSimulation;
    private JMenu mnuHelp;
    private JMenuItem mnuAbout;
    private JToolBar tblToolBar;
    private JButton btnLoadGraph;
    private JPanel pnlLog;
    private JPanel pnlInfo;
    private JPanel pnlGraphicArea;
    private JTextArea txtLog;
    private JLabel lblCurrentNode;
    private JPanel pnlNodeName;
    private JLabel lblNodeName;
    private JTextField txtVariableName;
    private JLabel lblCPT;
    private JTextArea txtCPTDump;
    private JLabel lambdaPiValues;
    private JTextArea txtLambdaPiVals;
    private JLabel lblLambdaPiMsgs;
    private JTextArea txtLambdaPiMsgs;
    private JPanel pnlCPT;
    private JPanel pnlLPVals;
    private JPanel pnlLPMsgs;

    private JDialog aboutDialog;
    private ChangeValues changeValuesDialog;
    private ActionListener loader;
    private ActionListener saver;
    private ActionListener nextStep;
    private ActionListener finishExecution;
    private ActionListener backExecution;
    private ActionListener restartExecution;
    private JButton btnNextStep;
    private JButton btnEnd;
    private JButton btnInstantiate;
    private InstantiationDialog instantiationDialog;
    private JPanel messagesPanel;
    private JPanel valuesPanel;
    private JPanel cptPanel;
    private JPanel probabilityPanel;
    private JLabel lblProbability;
    private JTextArea txtProbability;
    private JButton btnBack;
    private JButton btnRestart;

    private JFileChooser fileChooser;
    private JButton btnSaveGraph;
    private JButton btnChangeValues;
    private JButton btnCreateGraph;
    private JButton btnZoomIn;
    private JButton btnZoomOut;
    private JButton btnFinishCreating;
    private JMenuItem mnuCreateNewGraph;
    private JMenuItem mnuSaveGraph;
    private JMenuItem mnuRestart;
    private JMenuItem mnuBack;
    private JMenu mnOptions;
    private JMenuItem mnuInstantiate;
    private JMenuItem mnuChangeValues;
    private JMenuItem mnuZoomIn;
    private JMenuItem mnuZoomOut;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
	try {
	    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
	} catch (Throwable e) {
	    e.printStackTrace();
	}
	EventQueue.invokeLater(new Runnable() {
	    public void run() {
		try {
		    MainWindow window = new MainWindow();
		    window.frmBayesianNetworkSimulator.setVisible(true);
		} catch (Exception e) {
		    e.printStackTrace();
		}
	    }
	});
    }

    /**
     * Create the application.
     */
    public MainWindow() {
	initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
	frmBayesianNetworkSimulator = new JFrame();
	frmBayesianNetworkSimulator.setTitle("Bayesian Network Simulator - Pearl Algorithm");
	frmBayesianNetworkSimulator.setBounds(100, 100, 450, 300);
	frmBayesianNetworkSimulator.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	mnuMenuBar = new JMenuBar();
	frmBayesianNetworkSimulator.setJMenuBar(mnuMenuBar);

	mnuFileMenu = new JMenu("File");
	mnuFileMenu.setMnemonic('F');
	mnuMenuBar.add(mnuFileMenu);

	mnuCreateNewGraph = new JMenuItem("Create new graph");
	mnuCreateNewGraph.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-new.png")));
	mnuCreateNewGraph.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
	mnuFileMenu.add(mnuCreateNewGraph);

	mnuLoadFromFile = new JMenuItem("Load graph from file");
	mnuLoadFromFile.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-open.png")));
	mnuLoadFromFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK));
	mnuFileMenu.add(mnuLoadFromFile);

	mnuExit = new JMenuItem("Exit");
	mnuExit.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		frmBayesianNetworkSimulator.dispose();
	    }
	});

	mnuSaveGraph = new JMenuItem("Save graph");
	mnuSaveGraph.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-save-as.png")));
	mnuSaveGraph.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
	mnuFileMenu.add(mnuSaveGraph);
	mnuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK));
	mnuFileMenu.add(mnuExit);

	mnuSimulation = new JMenu("Simulation");
	mnuMenuBar.add(mnuSimulation);

	mnuRestart = new JMenuItem("Restart");
	mnuRestart.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-first.png")));
	mnuRestart.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK));
	mnuSimulation.add(mnuRestart);

	mnuBack = new JMenuItem("Back");
	mnuBack.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK));
	mnuBack.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-previous.png")));
	mnuSimulation.add(mnuBack);

	mnuNextStep = new JMenuItem("Next Step");
	mnuNextStep.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-next.png")));
	mnuNextStep.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK));
	mnuSimulation.add(mnuNextStep);

	mnuFinishSimulation = new JMenuItem("Finish Simulation");
	mnuFinishSimulation.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-last.png")));
	mnuFinishSimulation.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK));
	mnuSimulation.add(mnuFinishSimulation);

	mnOptions = new JMenu("Options");
	mnuMenuBar.add(mnOptions);

	mnuInstantiate = new JMenuItem("Instantiate");
	mnuInstantiate.setIcon(new ImageIcon(MainWindow.class.getResource("/images/star.png")));
	mnuInstantiate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
	mnOptions.add(mnuInstantiate);

	mnuChangeValues = new JMenuItem("Change Values");
	mnuChangeValues.setIcon(new ImageIcon(MainWindow.class.getResource("/images/cpt.png")));
	mnuChangeValues.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK));
	mnOptions.add(mnuChangeValues);

	mnuZoomIn = new JMenuItem("Zoom In");
	mnuZoomIn.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		AlgorithmController.instance().zoomIn();
	    }
	});
	mnuZoomIn.setIcon(new ImageIcon(MainWindow.class.getResource("/images/zoomin.png")));
	mnuZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK));
	mnOptions.add(mnuZoomIn);

	mnuZoomOut = new JMenuItem("Zoom Out");
	mnuZoomOut.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		AlgorithmController.instance().zoomOut();
	    }
	});
	mnuZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_MASK));
	mnuZoomOut.setIcon(new ImageIcon(MainWindow.class.getResource("/images/zoomout.png")));
	mnOptions.add(mnuZoomOut);

	mnuHelp = new JMenu("Help");
	mnuMenuBar.add(mnuHelp);

	mnuAbout = new JMenuItem("About");
	mnuAbout.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent arg0) {
		aboutDialogClicked();
	    }
	});
	mnuAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));
	mnuHelp.add(mnuAbout);

	tblToolBar = new JToolBar();
	frmBayesianNetworkSimulator.getContentPane().add(tblToolBar, BorderLayout.NORTH);

	btnCreateGraph = new JButton("Create Graph");
	btnCreateGraph.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		createGraphClicked();
	    }
	});
	btnCreateGraph.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-new.png")));
	tblToolBar.add(btnCreateGraph);

	btnLoadGraph = new JButton("Load");
	btnLoadGraph.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-open.png")));
	tblToolBar.add(btnLoadGraph);

	btnSaveGraph = new JButton("Save Graph");
	btnSaveGraph.setIcon(new ImageIcon(MainWindow.class.getResource("/images/document-save-as.png")));
	tblToolBar.add(btnSaveGraph);

	btnRestart = new JButton("Restart");
	btnRestart.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-first.png")));
	tblToolBar.add(btnRestart);

	btnBack = new JButton("Back");
	btnBack.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-previous.png")));
	tblToolBar.add(btnBack);

	btnNextStep = new JButton("Next");
	btnNextStep.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-next.png")));
	tblToolBar.add(btnNextStep);

	btnEnd = new JButton("End");
	btnEnd.setIcon(new ImageIcon(MainWindow.class.getResource("/images/go-last.png")));
	tblToolBar.add(btnEnd);

	btnInstantiate = new JButton("Instantiate");
	btnInstantiate.setIcon(new ImageIcon(MainWindow.class.getResource("/images/star.png")));
	btnInstantiate.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent arg0) {
		openInstantiationDialog();
	    }
	});
	tblToolBar.add(btnInstantiate);

	btnChangeValues = new JButton("Change Values");
	btnChangeValues.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent arg0) {
		changeValuesClicked();
	    }
	});
	btnChangeValues.setIcon(new ImageIcon(MainWindow.class.getResource("/images/cpt.png")));
	tblToolBar.add(btnChangeValues);

	btnZoomIn = new JButton("Zoom In");
	btnZoomIn.setIcon(new ImageIcon(MainWindow.class.getResource("/images/zoomin.png")));
	btnZoomIn.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent arg0) {
		AlgorithmController.instance().zoomIn();
	    }
	});
	tblToolBar.add(btnZoomIn);

	btnZoomOut = new JButton("Zoom Out");
	btnZoomOut.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		AlgorithmController.instance().zoomOut();
	    }
	});
	btnZoomOut.setIcon(new ImageIcon(MainWindow.class.getResource("/images/zoomout.png")));
	tblToolBar.add(btnZoomOut);

	btnFinishCreating = new JButton("Finish Creating");
	btnFinishCreating.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent arg0) {
		AlgorithmController.instance().finishedGraphDrawing();
	    }
	});
	btnFinishCreating.setIcon(new ImageIcon(MainWindow.class.getResource("/images/check.png")));
	tblToolBar.add(btnFinishCreating);

	pnlLog = new JPanel();
	pnlLog.setBorder(new TitledBorder(null, "Algorithm Output", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	// frmBayesianNetworkSimulator.getContentPane().add(pnlLog,
	// BorderLayout.EAST);
	pnlLog.setLayout(new BorderLayout(0, 0));

	txtLog = new JTextArea();
	txtLog.setBackground(new Color(204, 255, 204));
	txtLog.setLineWrap(true);

	JScrollPane scroller = new JScrollPane(txtLog);
	JScrollBar bar = new JScrollBar();
	scroller.add(bar);
	pnlLog.add(scroller, BorderLayout.CENTER);

	DefaultCaret caret = (DefaultCaret) txtLog.getCaret();
	caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

	pnlInfo = new JPanel();
	pnlInfo.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	frmBayesianNetworkSimulator.getContentPane().add(pnlInfo, BorderLayout.WEST);
	pnlInfo.setLayout(new GridLayout(VizualizationConstants.NUMBER_OF_ROWS_ON_INFO_PANEL, VizualizationConstants.NUMBER_OF_COLS_ON_INFO_PANEL,
		VizualizationConstants.GAP_ON_INFO_PANEL, VizualizationConstants.GAP_ON_INFO_PANEL));

	lblCurrentNode = new JLabel("CURRENT NODE");
	lblCurrentNode.setForeground(Color.BLUE);
	lblCurrentNode.setFont(new Font("Tahoma", Font.BOLD, 16));
	lblCurrentNode.setHorizontalAlignment(SwingConstants.CENTER);
	pnlInfo.add(lblCurrentNode);

	pnlNodeName = new JPanel();
	pnlInfo.add(pnlNodeName);

	lblNodeName = new JLabel("Variable Name:");
	pnlNodeName.add(lblNodeName);

	txtVariableName = new JTextField();
	txtVariableName.setFont(new Font("Tahoma", Font.BOLD, 15));
	txtVariableName.setHorizontalAlignment(SwingConstants.CENTER);
	txtVariableName.setEditable(false);
	txtVariableName.setForeground(Color.RED);
	txtVariableName.setText("");
	pnlNodeName.add(txtVariableName);
	txtVariableName.setColumns(10);

	probabilityPanel = new JPanel();
	pnlInfo.add(probabilityPanel);
	probabilityPanel.setLayout(new BorderLayout(0, 0));

	lblProbability = new JLabel("Probability");
	lblProbability.setHorizontalAlignment(SwingConstants.CENTER);
	lblProbability.setFont(new Font("Tahoma", Font.BOLD, 12));
	probabilityPanel.add(lblProbability, BorderLayout.NORTH);

	txtProbability = new JTextArea();
	txtProbability.setText("");
	txtProbability.setBackground(new Color(204, 255, 204));
	probabilityPanel.add(txtProbability, BorderLayout.CENTER);

	cptPanel = new JPanel();
	pnlInfo.add(cptPanel);
	cptPanel.setLayout(new BorderLayout(0, 0));

	lblCPT = new JLabel("Conditional Probability Table Dump");
	cptPanel.add(lblCPT, BorderLayout.NORTH);
	lblCPT.setHorizontalAlignment(SwingConstants.CENTER);
	lblCPT.setFont(new Font("Tahoma", Font.BOLD, 12));

	pnlCPT = new JPanel();
	cptPanel.add(pnlCPT);
	pnlCPT.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	pnlCPT.setLayout(new BorderLayout(0, 0));

	txtCPTDump = new JTextArea();
	txtCPTDump.setBackground(new Color(204, 255, 204));
	pnlCPT.add(txtCPTDump);

	valuesPanel = new JPanel();
	pnlInfo.add(valuesPanel);
	valuesPanel.setLayout(new BorderLayout(0, 0));

	lambdaPiValues = new JLabel("\u03BB and \u03C0 Values Dump");
	valuesPanel.add(lambdaPiValues, BorderLayout.NORTH);
	lambdaPiValues.setHorizontalAlignment(SwingConstants.CENTER);
	lambdaPiValues.setFont(new Font("Tahoma", Font.BOLD, 13));

	pnlLPVals = new JPanel();
	valuesPanel.add(pnlLPVals);
	pnlLPVals.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	pnlLPVals.setLayout(new BorderLayout(0, 0));

	txtLambdaPiVals = new JTextArea();
	txtLambdaPiVals.setBackground(new Color(204, 255, 204));
	pnlLPVals.add(txtLambdaPiVals);
	txtLambdaPiVals.setRows(10);

	messagesPanel = new JPanel();
	pnlInfo.add(messagesPanel);
	messagesPanel.setLayout(new BorderLayout(0, 0));

	lblLambdaPiMsgs = new JLabel("\u03BB and \u03C0 Messages Dump");
	messagesPanel.add(lblLambdaPiMsgs, BorderLayout.NORTH);
	lblLambdaPiMsgs.setHorizontalAlignment(SwingConstants.CENTER);
	lblLambdaPiMsgs.setFont(new Font("Tahoma", Font.BOLD, 13));

	pnlLPMsgs = new JPanel();
	messagesPanel.add(pnlLPMsgs);
	pnlLPMsgs.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	pnlLPMsgs.setLayout(new BorderLayout(0, 0));

	txtLambdaPiMsgs = new JTextArea();
	txtLambdaPiMsgs.setBackground(new Color(204, 255, 204));
	pnlLPMsgs.add(txtLambdaPiMsgs);
	txtLambdaPiMsgs.setText("");

	pnlGraphicArea = new JPanel();
	pnlGraphicArea.setBackground(new Color(255, 250, 250));
	// frmBayesianNetworkSimulator.getContentPane().add(pnlGraphicArea,
	// BorderLayout.CENTER);
	pnlGraphicArea.setLayout(new BorderLayout(0, 0));

	changeValuesDialog = new ChangeValues();

	int graphicsPreferedSize = Toolkit.getDefaultToolkit().getScreenSize().width / 2;
	int logPanelsPreferedSize = Toolkit.getDefaultToolkit().getScreenSize().width / 3;
	int infoPanelsPreferedSize = Toolkit.getDefaultToolkit().getScreenSize().width / 6;

	pnlGraphicArea.setPreferredSize(new Dimension(graphicsPreferedSize, VizualizationConstants.NO_PREFERED_HEIGHT));
	pnlLog.setPreferredSize(new Dimension(logPanelsPreferedSize, VizualizationConstants.NO_PREFERED_HEIGHT));
	pnlInfo.setPreferredSize(new Dimension(infoPanelsPreferedSize, VizualizationConstants.NO_PREFERED_HEIGHT));

	JSplitPane rightSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, pnlGraphicArea, pnlLog);

	JSplitPane leftSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, pnlInfo, rightSplit);

	frmBayesianNetworkSimulator.getContentPane().add(leftSplit, BorderLayout.CENTER);

	manualInitialization();
    }

    private void manualInitialization() {
	frmBayesianNetworkSimulator.setExtendedState(JFrame.MAXIMIZED_BOTH);
	pnlGraphicArea.setPreferredSize(new Dimension(VizualizationConstants.PREFERED_GRAPHICS_PANEL_WIDTH, VizualizationConstants.NO_PREFERED_HEIGHT));

	Dimension min = new Dimension(200, 200);
	pnlLog.setMinimumSize(min);
	pnlGraphicArea.setMinimumSize(min);

	aboutDialog = new AboutDialog();
	newNodeDialog = new NewNodeDialog();

	loader = new LoadGraphEventHandler(this);
	saver = new SaveGraphEventHandler(this);
	nextStep = new ContinueButton();
	finishExecution = new FinishAlgorithm();
	backExecution = new BackButton();
	restartExecution = new RestartButton();

	btnLoadGraph.addActionListener(loader);
	btnNextStep.addActionListener(nextStep);
	btnEnd.addActionListener(finishExecution);
	btnBack.addActionListener(backExecution);
	btnRestart.addActionListener(restartExecution);
	btnSaveGraph.addActionListener(saver);
	mnuLoadFromFile.addActionListener(loader);
	mnuNextStep.addActionListener(nextStep);
	mnuFinishSimulation.addActionListener(finishExecution);
	mnuBack.addActionListener(backExecution);
	mnuRestart.addActionListener(restartExecution);

	mnuCreateNewGraph.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		createGraphClicked();
	    }
	});
	mnuSaveGraph.addActionListener(saver);

	mnuInstantiate.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		openInstantiationDialog();
	    }
	});

	mnuChangeValues.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		changeValuesClicked();
	    }
	});

	enableAlgorithmControllButtons(false); // disable buttons until load
					       // graph

	btnFinishCreating.setVisible(false);

	JTextAreaLogger.instance().setPlaceToLog(txtLog);

	instantiationDialog = new InstantiationDialog();

	fileChooser = new JFileChooser();

	frmBayesianNetworkSimulator.pack();

	AlgorithmController.instance().setData(this);
    }

    public void enableAlgorithmControllButtons(boolean enabled) {
	btnRestart.setEnabled(enabled);
	btnBack.setEnabled(enabled);
	btnNextStep.setEnabled(enabled);
	btnEnd.setEnabled(enabled);

	mnuRestart.setEnabled(enabled);
	mnuBack.setEnabled(enabled);
	mnuNextStep.setEnabled(enabled);
	mnuFinishSimulation.setEnabled(enabled);
    }

    protected void enterCreatingMode() {
	AlgorithmController.instance().enterCreatingMode();
    }

    protected void changeValuesClicked() {
	changeValuesDialog.setVisible(true);
    }

    private void openInstantiationDialog() {
	instantiationDialog.setVisible(true);
	// instantiationDialog.initData();
    }

    private void aboutDialogClicked() {
	aboutDialog.setVisible(true);
    }

    public JPanel getPnlGraphicArea() {
	return pnlGraphicArea;
    }

    public void setPnlGraphicArea(JPanel pnlGraphicArea) {
	this.pnlGraphicArea = pnlGraphicArea;
    }

    public JTextField getTxtVariableName() {
	return txtVariableName;
    }

    public void setTxtVariableName(String txtVariableName) {
	this.txtVariableName.setText(txtVariableName);
    }

    public JTextArea getTxtCPTDump() {
	return txtCPTDump;
    }

    public void setTxtCPTDump(String txtCPTDump) {
	this.txtCPTDump.setText(txtCPTDump);
    }

    public JTextArea getTxtLambdaPiVals() {
	return txtLambdaPiVals;
    }

    public void setTxtLambdaPiVals(String txtLambdaPiVals) {
	this.txtLambdaPiVals.setText(txtLambdaPiVals);
    }

    public JTextArea getTxtLambdaPiMsgs() {
	return txtLambdaPiMsgs;
    }

    public void setTxtLambdaPiMsgs(String txtLambdaPiMsgs) {
	this.txtLambdaPiMsgs.setText(txtLambdaPiMsgs);
    }

    public JFrame getFrmBayesianNetworkSimulator() {
	return frmBayesianNetworkSimulator;
    }

    public void setFrmBayesianNetworkSimulator(JFrame frmBayesianNetworkSimulator) {
	this.frmBayesianNetworkSimulator = frmBayesianNetworkSimulator;
    }

    public JTextArea getTxtProbability() {
	return txtProbability;
    }

    public void setTxtProbability(String txtProbability) {
	this.txtProbability.setText(txtProbability);
	;
    }

    public JFileChooser getFileChooser() {
	return fileChooser;
    }

    public void setFileChooser(JFileChooser fileChooser) {
	this.fileChooser = fileChooser;
    }

    public JPanel getPnlInfo() {
	return pnlInfo;
    }

    public void setPnlInfo(JPanel pnlInfo) {
	this.pnlInfo = pnlInfo;
    }

    public JButton getBtnFinishCreating() {
	return btnFinishCreating;
    }

    public void setBtnFinishCreating(JButton btnFinishCreating) {
	this.btnFinishCreating = btnFinishCreating;
    }

    private void createGraphClicked() {
	enterCreatingMode();
	btnFinishCreating.setVisible(true);
    }
}
